package com.zhao.service.Impl;

import com.zhao.pojo.Dept;
import com.zhao.service.DeptClientService;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName:DeptClientServiceFallbackFactory
 * @author:赵培舒
 * @date:Created in 2021/4/23 10:09
 * @Email:stevezhao@nyist.edu.cn
 * @description:实现类
 * @version:1.0
 */

@Component //给spring托管
public class DeptClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public Object create(Throwable throwable) {
        return new DeptClientService() {
            @Override
            public Dept queryById(Long id) {
                return new Dept().setDeptno(id)
                                 .setDeptname("“id=>"+id+"没有对应的信息，客服端提供了降级服务，这个服务现在已经被关闭")
                                  .setDb_source("没有数据");
            }

            @Override
            public List<Dept> queryAll() {
                return null;
            }

            @Override
            public boolean addDept(Dept dept) {
                return false;
            }
        };
    }
}
